<?php 
require_once '../../includefiles.php';
require_once '../../model/users.php';

if($_SESSION['getbids_id']!='')
{
	header("Location: ".SITE_URL."/");
	exit;		
}


$userObj =new Model_Users();

if($_GET['id1']!='')
{
	$user_res=$userObj->getUserValueByEncryptedId($_GET['id1']);
	$smarty->assign('user_res', $user_res);	
}


if(isset($_POST['reset']))
{   
	if(trim($_POST['pass']) != '') 
	{					
		$adminArray				= array();
		$adminArray['password']	= md5($_POST['pass']);
		$userObj->editUserValueById($adminArray,$user_res['id']);
		$_SESSION['sucmsg'] = "<div class='success_msg'><span>Your Password Changed Successfully!</span></div>";	
		redirect_to_link(SITE_URL."/signin/signin/");					

	} else { // password else
		$_SESSION['error'] = 'Please enter your new password';				
	}
}

if($_SESSION['sucmsg']!=''){
	$smarty->assign("successMsg", $_SESSION['sucmsg']);
	unset($_SESSION['sucmsg']);
}

if($_SESSION['error'] != ''){	
	$smarty->assign("errorMsg", $_SESSION['error']);	
	unset($_SESSION['error']);
}

//Active Class
$active = 'login';
$smarty->assign('active', $active);

## Unset all the objects created which are on this page
unset($userObj);

$smarty->display(TEMPLATEDIR.'/modules/signin/resetpassword.tpl');
unset($smarty);
?>
